package jspservlet.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jspservlet.dao.UserDAO;
import jspservlet.dao.impl.UserDAOImpl;
import jspservlet.vo.User;
import javax.servlet.http.HttpSession;


public class ShowUserInfoServelt {
    public void doGet(HttpServletRequest req, HttpServletResponse res)
			throws ServletException, IOException {
	}
	public void doPost(HttpServletRequest req, HttpServletResponse res)
			throws ServletException, IOException {
		    UserDAO dao=new UserDAOImpl();
		HttpSession session=req.getSession();
        User user = new User();
        String username = (String)session.getAttribute("username");
		user.setUsername(req.getParameter(username));
    
		int flag = 0;
		try {
			flag = dao.showUserInfo(user,session);
		} 
		catch (Exception e) {
			e.printStackTrace();
		}
		if(flag == 1){
			res.getWriter().println("<script>alert('Registration Successful!')</script>");
			res.getWriter().println("<script>window.location.href='./index.jsp'</script>");
		}
		else{
			res.getWriter().println("<script>alert('Registration Failed!')</script>");
			res.getWriter().println("<script>window.location.href='./RegisterFamily.jsp'</script>");
		}
	}
}
